Link to this headingGPG

GPG (GNU Privacy Guard) is an open-source implementation of the OpenPGP standard for cryptographic privacy and authentication. It provides digital encryption and signing services using public key cryptography.

Tutorials:

For detailed command reference, see GPG Commands.

Link to this headingKey Servers

Get Keyserver Certificate:

wget https://sks-keyservers.net/sks-keyservers.netCA.pem -O /etc/ca-certificates/extracted/sks-keyservers.netCA.pem

Link to this headingKey management

Keeping your primary key entirely offline:

# Extract the primary key gpg -a --export-secret-key [email protected] > secret_key # Extract the subkeys, which we will reimport later gpg -a --export-secret-subkeys [email protected] > secret_subkeys.gpg # Delete the secret keys from the keyring, so only subkeys are left gpg --delete-secret-keys [email protected] Delete this key from the keyring? (y/N) y This is a secret key! - really delete? (y/N) y # Reimport the subkeys gpg --import secret_subkeys.gpg # Verify everything is in order gpg --list-secret-keys # Remove the subkeys from disk rm secret_subkeys.gpg

Link to this headingGPG Config

~/.gnupg/gpg.conf

# # This is an implementation of the Riseup OpenPGP Best Practices # https://help.riseup.net/en/security/message-security/openpgp/best-practices # #----------------------------- # default key #----------------------------- # The default key to sign with. If this option is not used, the default key is # the first key found in the secret keyring #default-key 0xD8692123C4065DEA5E0F3AB5249B39D24F25E3B6 #----------------------------- # behavior #----------------------------- # Disable inclusion of the version string in ASCII armored output no-emit-version # Disable comment string in clear text signatures and ASCII armored messages no-comments # Display long key IDs keyid-format 0xlong # List all keys (or the specified ones) along with their fingerprints with-fingerprint # Display the calculated validity of user IDs during key listings list-options show-uid-validity verify-options show-uid-validity # Try to use the GnuPG-Agent. With this option, GnuPG first tries to connect to # the agent before it asks for a passphrase. use-agent # Set default charset charset utf-8 #----------------------------- # keyserver #----------------------------- # This is the server that --recv-keys, --send-keys, and --search-keys will # communicate with to receive keys from, send keys to, and search for keys on keyserver hkps://hkps.pool.sks-keyservers.net # Provide a certificate store to override the system default # Get this from https://sks-keyservers.net/sks-keyservers.netCA.pem keyserver-options ca-cert-file=/path/to/CA/sks-keyservers.netCA.pem # Set the proxy to use for HTTP and HKP keyservers - default to the standard # local Tor socks proxy # It is encouraged to use Tor for improved anonymity. Preferably use either a # dedicated SOCKSPort for GnuPG and/or enable IsolateDestPort and # IsolateDestAddr #keyserver-options http-proxy=socks5-hostname://127.0.0.1:9050 # Don't leak DNS, see https://trac.torproject.org/projects/tor/ticket/2846 keyserver-options no-try-dns-srv # When using --refresh-keys, if the key in question has a preferred keyserver # URL, then disable use of that preferred keyserver to refresh the key from keyserver-options no-honor-keyserver-url # When searching for a key with --search-keys, include keys that are marked on # the keyserver as revoked keyserver-options include-revoked #----------------------------- # algorithm and ciphers #----------------------------- # Assume that command line arguments are given as UTF8 strings. utf8-strings # when outputting certificates, view user IDs distinctly from keys: fixed-list-mode # long keyids are more collision-resistant than short keyids (it's trivial to make a key # Long key IDs are more collision-resistant than short key IDs (it's trivial to make a key # NOTE: this breaks kmail gnupg support! keyid-format 0xlong # when multiple digests are supported by all recipients, choose the strongest one: personal-digest-preferences SHA512 SHA384 SHA256 SHA224 # preferences chosen for new keys should prioritize stronger algorithms: default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 BZIP2 ZLIB ZIP Uncompressed # You should always know at a glance which User IDs GPG thinks are legitimately bound to # the keys in the keyring: verify-options show-uid-validity list-options show-uid-validity # when making an OpenPGP certification, use a stronger digest than the default SHA1: cert-digest-algo SHA512 s2k-cipher-algo AES256 s2k-digest-algo SHA512

Link to this headingGenerate Key and Subkeys

Creating the Perfect Key pair
GPG Subkeys
Using a Yubikey for GPG and SSH